{include file="public_iframe:head" xmlns:H="http://www.w3.org/1999/xhtml"/}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>顾问编辑</h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>
        <div class="ibox-content">
            <form action="" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                <input type="hidden" name="id" value="{$da.id?$da.id:'';}">
                <div class="form-group">
                    <label class="col-sm-2 control-label">顾问名</label>
                    <div class="col-sm-6">
                        <input type="text" name="advisername" id="advisername" value="{$da.advisername?$da.advisername:'';}" class="form-control" placeholder="顾问名" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">顾问级别</label>
                    <div class="col-sm-6">
                        <input type="text" name="level" id="level" value="{$da.level?$da.level:'';}" class="form-control" placeholder="顾问级别" >
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">头像</label>
                    <div class="col-sm-3">
                        <input type="file" name="image" class="form-control">
                    </div>
                    <div class="col-sm-3">
                        (备注: 宽度830  高度330;) {if condition="isset($da.head_img)"}<img src="__STATIC__/uploads/$da.head_img" alt="">{/if}
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">业务范围</label>
                    <div class="col-sm-6">
                        <input type="text" name="item" id="item" value="{$da.item?$da.item:'';}" class="form-control" placeholder="业务范围" >
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">业务介绍</label>
                    <div class="col-sm-6">
                        <input type="text" name="introduction" id="introduction" value="{$da.introduction?$da.introduction:'';}" class="form-control" placeholder="业务介绍" >
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">是否认证</label>
                    <div class="col-sm-6">
                        <label class="checkbox-inline">
                            <input type="radio" name="is_zheng"  value="1"  {if condition="isset($da.is_zheng) and $da.is_zheng=='1'"} checked="checked"{/if}>已认证
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="is_zheng"  value="-1"  {if condition="isset($da.is_zheng) and $da.is_zheng=='-1'"} checked="checked"{/if}>未认证
                        </label>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">是否诚诺</label>
                    <div class="col-sm-6">
                        <label class="checkbox-inline">
                            <input type="radio" name="is_nuo"  value="1"  {if condition="isset($da.is_nuo) and $da.is_nuo=='1'"} checked="checked"{/if}>已诚诺
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="is_nuo"  value="-1"  {if condition="isset($da.is_nuo) and $da.is_nuo=='-1'"} checked="checked"{/if}>未诚诺
                        </label>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">性别</label>
                    <div class="col-sm-6">
                        <label class="checkbox-inline">
                            <input type="radio" name="sex"  value="1"  {if condition="isset($da.sex) and $da.sex=='1'"} checked="checked"{/if}>男
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="sex"  value="2"  {if condition="isset($da.sex) and $da.sex=='2'"} checked="checked"{/if}>女
                        </label>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">状态</label>
                    <div class="col-sm-6">
                        <label class="checkbox-inline">
                            <input type="radio" name="status"  value="1"  {if condition="isset($da.status) and $da.status=='1'"} checked="checked"{/if}>启用
                        </label>
                        <label class="checkbox-inline">
                            <input type="radio" name="status"  value="-1"  {if condition="isset($da.status) and $da.status=='-1'"} checked="checked"{/if}>禁用
                        </label>
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">排序</label>
                    <div class="col-sm-6">
                        <input type="text" name="sort" id="sort" value="{$da.sort?$da.sort:'';}" class="form-control" placeholder="数字越大越靠前" >
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <!--<button class="btn btn-primary" type="submit">提交</button>-->
                        <!--href="JavaScript:void(0);" onclick="roleSubmit();"-->
                        <a href="JavaScript:void(0);" onclick="Submit();" class="btn btn-primary" id="submit">提交</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- End Panel Basic -->
</div>
<script>

    function Submit(){
        var formData = new FormData();
        var id = $('input[name="id"]').val();
        var advisername = $('input[name="advisername"]').val();
        var level = $('input[name="level"]').val();
        var item = $('input[name="item"]').val();
        var introduction = $('input[name="introduction"]').val();
        var is_zheng = $('input[name="is_zheng"]:checked').val();
        var is_nuo = $('input[name="is_nuo"]:checked').val();
        var sex = $('input[name="sex"]:checked').val();
        var status = $('input[name="status"]:checked').val();
        var file = $('input[name="image"]');
        var image = file.get(0).files[0];
        var sort = $('input[name="sort"]').val();

        formData.append('id',id);
        formData.append('advisername',advisername);
        formData.append('level',level);
        formData.append('item',item);
        formData.append('introduction',introduction);
        formData.append('is_zheng',is_zheng);
        formData.append('is_nuo',is_nuo);
        formData.append('sex',sex);
        formData.append('status',status);
        formData.append('image',image);
        formData.append('sort',sort);

        $.ajax({
            url:"{:url('Adviser/edit')}",
            type:'POST',
            data:formData,
            async:false,
            processData:false,
            contentType:false,
            success:function(result) {
                if(result.code == '0'){
                    parent.layer.alert(result.msg);
                }else{
                    parent.layer.msg(result.msg,{
                                icon:1,
                                time:1000,
                            },
                            function (index, item) {
                                location.href = result.url;
                            });
                }
            }
        });
    }
</script>
</body>

</html>